const Router = require('koa-router');
const router = new Router({ prefix: global.urlBase });
const executiveCommand = require('../db/index')
const { getToken } = require('./controllers')
const bodyMessage = {
    success(msg, data) {
        return {
            code: 200,
            data
        }
    },
    error(msg = '失败') {
        return {
            code: 400,
            msg
        }
    }
}
router.post('/login', async ctx => {
    try {
        let result = await getToken(ctx.request.body)
        ctx.body = bodyMessage.success(result.msg, result.data)
    } catch (error) {
        ctx.body = bodyMessage.error(error)
    }
});
router.get('/user', async (ctx) => {
    // 获取用户列表的逻辑
    ctx.body = ctx.username
});
module.exports = router